package com.gwm.page.listener;


import com.gwm.page.service.PageService;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.gwm.common.constants.RocketMQConstants.*;
import static com.gwm.common.constants.RocketMQConstants.CONSUMER.ITEM_PAGE_DOWN_CONSUMER;
import static com.gwm.common.constants.RocketMQConstants.TAGS.ITEM_DOWN_TAGS;
import static com.gwm.common.constants.RocketMQConstants.TOPIC.ITEM_TOPIC_NAME;


@Component
@RocketMQMessageListener(consumerGroup=ITEM_PAGE_DOWN_CONSUMER,
        topic =ITEM_TOPIC_NAME,
        selectorExpression = ITEM_DOWN_TAGS,
        messageModel= MessageModel.BROADCASTING)
public class ItemDownListener implements RocketMQListener<Long> {


    @Autowired
    private PageService pageService;


    @Override
    public void onMessage(Long spuId) {
        pageService.deleteHtml(spuId);
        System.out.println("静态页面删除成功........");

    }
}
